/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nc.kyiv.yellow.sociallibrary.books;

import com.nc.kyiv.yellow.sociallibrary.dao.BookDAO;
import com.nc.kyiv.yellow.sociallibrary.helper.MapBuilder;
import com.nc.kyiv.yellow.sociallibrary.similarUse.CommonClassesInterface;
import java.util.Map;

/**
 *
 * @author Alena
 */
public class SetModerStatus implements CommonClassesInterface{

    private String userId;

    public SetModerStatus(String userID) {
        this.userId = userID;
    }
    private String[] mapKeys = {"isbn", "moderStatus"};
    private MapBuilder helper = new MapBuilder();
    private String resultString = null;
    
    @Override
    public String execute(String parameters) throws Exception {
       Map postParameters = helper.stringToMap(parameters, mapKeys, helper.getRequestSplitter());
      
       System.out.println("in setModerStatus execute");
       System.out.println(postParameters);

       
        try {
            if (postParameters != null) {
                    BookDAO book = new BookDAO();
                    resultString = book.setModerStatus(postParameters);
            }
        } catch (Exception ex) {
           if (ex.getMessage().equals("Something is wrong with Data Base")) {
                return "failed";
            }   else {
               System.out.println("Exception during SetModerStatus: "+ex.getMessage());
               return "failed";
           }         
        }       
        return resultString;    
    }
}
